package com.atguigu.gmall.all.controller;

import com.atguigu.gmall.model.order.OrderInfo;
import com.atguigu.gmall.order.client.OrderFeignClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * @author atguigu-mqx
 */
@Controller
public class PaymentController {

    @Autowired
    private OrderFeignClient orderFeignClient;

    //  http://payment.gmall.com/pay.html?orderId=222
    @GetMapping("pay.html")
    public String pay(Long orderId, Model model){
        //  后台需要保存一个orderInfo 对象
        OrderInfo orderInfo = orderFeignClient.getOrderInfo(orderId);
        model.addAttribute("orderInfo",orderInfo);
        //  返回页面视图名称
        return "payment/pay";
    }

    //  支付成功之后，重定向到这个控制器返回支付成功页面！
    @GetMapping("pay/success.html")
    public String paySuccess(){
        //  返回支付成功页面！
        return "payment/success";
    }
}
